﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="EditFormEditor.aspx.cs" Inherits="Apollo.Website.EditFormEditor" %>
<%@ Register Src="~/Controls/HeaderJavaScript.ascx" TagPrefix="apollo" TagName="HeaderJavaScript" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <base target="_self" />
    <title></title>
    <apollo:HeaderJavaScript runat="server" />
    <link href="/css/apollo.preview.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="/js/apollo.formeditor.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {

            var group = null;
            var $destinationTable = $("#table1");
            /* new apolloGroupProperty("#table1", "General", [
            { col: 0, row: 0, type: "Required", name: "Name" },
            { col: "1", row: "0", type: "ReadOnly", name: "Id" },
            { col: "1", row: "1", type: "Normal", name: "AccountType" },
            { col: "0", row: "1", colspan: 2, type: "Recommanded", name: "Code" },
            { col: "0", row: "2", type: "Normal", customcontrol: "Relation", name: "Position" },
            { col: 1, row: 2, type: "Normal", name: "DefaultContact" }
            ]);*/


            $("#ClientRefresh").click(function () {

                // clear destination table
                $destinationTable.empty();

                var clientXml = $.parseXML($("textarea.ClientXml").val());
                var $clientXml = $(clientXml);

                $clientXml.find("group").each(function () {
                    var group_name = $(this).attr("displayname");

                    var properties = [];

                    $(this).find("property").each(function () {
                        var property = {};
                        property.col = $(this).attr("col");
                        property.row = $(this).attr("row");
                        property.type = $(this).attr("type");
                        property.name = $(this).text();

                        if ($(this).attr("customcontrol"))
                            property.customcontrol = $(this).attr("customcontrol");

                        properties.push(property);
                    });

                    var $destination_group = $("<div />");
                    $destinationTable.append($destination_group);

                    new apolloGroupProperty($destination_group, group_name, properties);
                });


            });


            // initialize
            $("#ClientRefresh").click();
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <div class="ui-state-hover">
            <div id="entity_menu" class="center-menu">
                <span class="alignRight"><a href="javascript:ModalReturn(-1);"><img src="/css/icons/icon_37.png" border="0" /> Close</a></span>
                <span style="display: none">
                    <select id="posible_fields">
                        <option value="Name">Name</option>
                    </select>
                </span>
                <span style="display: none"><a href="javascript:return false;"><img src="/css/icons/arrow_left.png" border="0" /></a></span>
                <span style="display: none"><a href="javascript:return false;"><img src="/css/icons/arrow_up.png" border="0" /></a></span>
                <span style="display: none"><a href="javascript:return false;"><img src="/css/icons/arrow_down.png" border="0" /></a></span>
                <span style="display: none"><a href="javascript:return false;"><img src="/css/icons/arrow_right.png" border="0" /></a></span>

                <span><asp:Image ID="ImageEntityIcon" runat="server" ImageUrl="css/icons/icon_01.png" ImageAlign="Left" /><asp:Label ID="LabelEntityName" runat="server" Text="Entity not set"></asp:Label></span>
                <span class="alignRight"><a id="ClientRefresh" href="javascript:return false;"><img src="/css/icons/icon_42.png" border="0" /> Refresh</a></span>
                

                <span style="display: none"><a href="javascript:addTab();" title="Remove tab"><img src="/css/icons/icon_93.png" border="0" alt="Remove tab" /></a></span>
                <span style="display: none"><a href="javascript:deleteTab();" title="Remove tab"><img src="/css/icons/icon_91.png" border="0" alt="Remove tab" /></a></span>
            </div>
            <div class="clear"></div>
        </div>

        <div id="tabs">
            <ul>
		        <li><a href="#tabs-0">General</a></li>
                <li><a href="#tabs-n"> <img src="/css/icons/icon_30.png" border="0" align="left" /> Add tab</a></li>
    	    </ul>
            <div id="tabs-0">
                <div id="table1" style="margin-bottom: 20px"></div>
                <!--a href="#"> <img src="/css/icons/icon_30.png" border="0" align="left" /> Add group</a-->
            </div>
            <div id="tabs-n"><img src="/css/apollo/loading16x16.gif"</div>
        </div>

        <div id="dialog" title="Tab title" style="display:none;">
			<label for="tab_title">Title</label>
			<input type="text" name="tab_title" id="tab_title" value="" class="ui-widget-content ui-corner-all" />
    	</div>

        <asp:TextBox ID="TextBoxClientXml" runat="server" CssClass="ClientXml" style="height:250px;width:600px;" TextMode="MultiLine"></asp:TextBox>

    </form>

    
</body>
</html>
